///////////////////////////////////////////////////////////
//  GameTimerHighResolution.cpp
//  Implementation of the Class GameTimerHighResolution
//  Created on:      11-Jan-2015 4:37:12 PM
//  Original author: Eng. Ahmed Yasser
///////////////////////////////////////////////////////////

#include "GameTimerHighResolution.h"

using EngineGame::EngineUtilities::GameTimerHighResolution;

GameTimerHighResolution::GameTimerHighResolution()
{

}

GameTimerHighResolution::~GameTimerHighResolution()
{

}

GameTimerHighResolution::GameTimerHighResolution(const GameTimerHighResolution& theGameTimerHighResolution)
	: _currentTime(theGameTimerHighResolution._currentTime)
	, _frequency(theGameTimerHighResolution._frequency)
	, _redundentTime(theGameTimerHighResolution._redundentTime)
{

}

double GameTimerHighResolution::getElapsedTime()
{
	LARGE_INTEGER curTime;
	QueryPerformanceCounter(&curTime);

	return (double(curTime.QuadPart - _currentTime.QuadPart) / double(_frequency.QuadPart)) - _redundentTime;
}


void GameTimerHighResolution::initTimer()
{
	QueryPerformanceFrequency(&_frequency);
	LARGE_INTEGER curTime;
	QueryPerformanceCounter(&curTime);
	QueryPerformanceCounter(&_currentTime);

	_redundentTime = double(curTime.QuadPart - _currentTime.QuadPart) / double(_frequency.QuadPart);
}


void GameTimerHighResolution::startTimer()
{
	QueryPerformanceCounter(&_currentTime);
}